#include "Object.h"


Object::Object()
{
 
}

Object::Object(float x, float y)
{
	_x = x;
	_y = y;
	/*_rectBond.left = _x;
	_rectBond.top = _y;
	_rectBond.right = _rectBond.left + _sprite->texture->_Width;
	_rectBond.bottom = _rectBond.top + _sprite->texture->_Height;*/
	//ResetRect();

	container = NULL;
	direction = 0;
}

Object::Object(float x, float y, float width, float height)
{
	_x = x;
	_y = y;

	/*rect.left = _x;
	rect.top = _y;
	rect.right = rect.left + width;
	rect.bottom = rect.top + height;*/
	//ResetRect();
}
 
Object::~Object()
{
	/*if (_sprite != NULL)
	{

	delete _sprite;
	_sprite = NULL;

	}*/
}


void Object::Update(int _ScreenWidth, int _ScreenHeight, float gameTime)
{
	 
}
 
void Object::Render()
{
 
	_sprite->Render(_x, _y);
	
 }

bool Object::IsCollideWith(Object* another)
{


	RECT rectOther = another->GetBond();
	RECT des;
	if (IntersectRect(&des, &rectOther, &_rectBond))
		return true;
	else
		return false;
}

RECT Object::GetIntersectBond(Object* another)
{
	RECT rectOther = another->GetBond();
	RECT des;
	IntersectRect(&des, &rectOther, &_rectBond);
	return des;
}

bool Object::IsPointIn(D3DXVECTOR2 point)
{
	if ((point.x >= _rectBond.left) && (point.x <= _rectBond.right) && (point.y >= _rectBond.top) && (point.y <= _rectBond.bottom))
		return true;
	else
		return false;
}

void Object::ResetRect()
{
	_rectBond.left = _x;
	_rectBond.right = _rectBond.left + _sprite->texture->_Width;
	_rectBond.top = _y;
	_rectBond.bottom = _rectBond.top + _sprite->texture->_Height;
}

OBJECT_TYPE Object::GetTypeObject()
{
	return OBJECT_SCENE;
}

 